let state=false;
$(document).ready(function() {
    $(function () {
        $("#newPwd").click(function () {
            let userId = localStorage.getItem("userId_forget");
            let userPwd1 = $("#register-userPwd1").val();
            let userPwd2 = $("#register-userPwd2").val();
            console.log(userId);
            if(userPwd1 === userPwd2){
                state=true;
            }
            if(userPwd1===null){
                swal({title: "密码不能为空！请重新输入！", type: "error"})
            }else if(state=true){
                console.log(userPwd1);
                $.ajax({
                    url: '/user/upDateUserPwd',
                    type: 'post',
                    dataType: 'json',
                    data: {"userId": userId, "userPwd": userPwd1},
                    success: function () {
                        swal({
                                title: "密码修改成功，请登录！",
                                type: "success",
                                confirmButtonColor: "#2a67ec",
                                confirmButtonText: "继续！"
                            },
                            function (isConfirm) {
                                if (isConfirm) {
                                    window.location.href = "../web/login.html";
                                }
                            });
                    }

                });
            }else{
                swal({title: "两次密码输入不一致！请重新输入！", type: "error"})
            }
        })
    })
})